﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ControlFace
{
    public static class Common
    {
        public static User My { get; set; }

        #region 只显示在线
        static bool showOnlineOnly = false;
        public static bool ShowOnlineOnly
        {
            get { return showOnlineOnly; }
            set
            {
                if (showOnlineOnly != value)
                {
                    showOnlineOnly = value;

                    if (ShowOnlineOnlyChanged != null)
                        ShowOnlineOnlyChanged(showOnlineOnly);
                }
            }
        }
        public delegate void ShowOnlineOnlyChangedHandler(bool showOnlineOnly);
        public static event ShowOnlineOnlyChangedHandler ShowOnlineOnlyChanged;
        #endregion

        //拖动换组
        public delegate void DragDropUserHandler(User user, Group newGroup);
        public static event DragDropUserHandler DragDropUser;
        public static void ToDragDropUser(User User, Group NewGroup)
        {
            if (DragDropUser != null)
                DragDropUser(User, NewGroup);
        }

        static AllUsers allUsers = new AllUsers();
        public static AllUsers AllUsers
        {
            get { return allUsers; }
            set { allUsers = value; }
        }
    }
    [Serializable]
    public class AllUsers : List<User>
    {
        public User this[string UserID]
        {
            get
            {
                User user = this.Find(u => u != null && u.UserID.Trim().ToLower() == UserID.Trim().ToLower());
                return user;
            }
        }
    }
}
